﻿<controls:ChildWindow 
	xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
	xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	xmlns:map_namespace="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl"
	xmlns:local="clr-namespace:BuildARoute"
	x:Class="BuildARoute.Views.CreateTourWindow"
	Width="900" Height="600" Background="White" BorderBrush="{x:Null}" mc:Ignorable="d"
	DataContext="{Binding RelativeSource={RelativeSource Self}}">

    
    <controls:ChildWindow.Resources>
        
        <CollectionViewSource x:Key="poiCollectionViewSource"/>
        
        <DataTemplate x:Key="tourDataFormEditTemplate">
            <StackPanel>
                <toolkit:DataField Label="Title">
                    <TextBox Text="{Binding Title, Mode=TwoWay}"/>
                </toolkit:DataField>
                <toolkit:DataField Label="Language">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock x:Name="languageTextBox" Text="{Binding Language}"/>
                        <ComboBox x:Name="languageComboBox"
							DataContext="{StaticResource languageCollectionViewSource}"
							ItemsSource="{Binding}" DisplayMemberPath="Name"
							SelectionChanged="languageComboBox_SelectionChanged"
							Width="100"/>
                    </StackPanel>
                </toolkit:DataField>
                <toolkit:DataField Label="Image">
                    <TextBox x:Name="imagePath" Text="{Binding ImageURI, Mode=TwoWay}"/>
                </toolkit:DataField>
                <toolkit:DataField Label="Short Description">
                    <TextBox Text="{Binding ShortDescription, Mode=TwoWay}"
						Height="60" AcceptsReturn="True"
                        TextAlignment="Left" TextWrapping="Wrap"/>
                </toolkit:DataField>
            </StackPanel>
        </DataTemplate>

        <DataTemplate x:Key="poiDataFormEditTemplate">
            <StackPanel Background="Aquamarine">
                <toolkit:DataField Label="POI Title">
                    <TextBox Text="{Binding Title,Mode=TwoWay}"/>
                </toolkit:DataField>
                <toolkit:DataField Label="Language">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock x:Name="poiLanguageTextBox" Text="{Binding Language, Mode=OneWay}" />
                    </StackPanel>
                </toolkit:DataField>
                <toolkit:DataField Label="Location" >
                    <StackPanel Orientation="Horizontal">
                        <TextBox x:Name="poiLatitudeTextBox" Text="{Binding Latitude, Mode=TwoWay}" Width="Auto"/>
                        <TextBox x:Name="poiLongitudeTextBox" Text="{Binding Longitude, Mode=TwoWay}" Width="Auto"/>
                    </StackPanel>
                </toolkit:DataField>
                <toolkit:DataField Label="Duration">
                    <TextBox Text="{Binding Duration, Mode=TwoWay}"/>
                </toolkit:DataField>
                <toolkit:DataField Label="Image">
                    <TextBox x:Name="imagePath" Text="{Binding ImageURI, Mode=TwoWay}"/>
                </toolkit:DataField>
                <toolkit:DataField Label="Short Description">
                    <TextBox Text="{Binding ShortDescription, Mode=TwoWay}"
						Height="60" AcceptsReturn="True" TextAlignment="Left" TextWrapping="Wrap" />
                </toolkit:DataField>
            </StackPanel>
        </DataTemplate>
    </controls:ChildWindow.Resources>
    
	<toolkit:BusyIndicator IsBusy="{Binding IsBusyIndicatorOn}">
        <Grid Name="LayoutRoot">
            <Grid.RowDefinitions>
                <RowDefinition x:Name="TitleRow" Height="Auto"/>
                <RowDefinition x:Name="MainRow" Height="*" />
                <RowDefinition x:Name="WindowsCloseButtonRow" Height="Auto"/>
            </Grid.RowDefinitions>


            <!--The first row should only contain the Tour Title -->
            <TextBlock Name="tourTitleTextBlock"
                       Grid.Row="0" HorizontalAlignment="Center"
                       TextWrapping="Wrap" Text="{Binding CurrentTour.Title, TargetNullValue=NullTourTitle}"
					   FontSize="48" FontFamily="Edwardian Script ITC"
					   Foreground="{StaticResource ApplicationNameBrush}"/>
        
            <Grid Grid.Row="1">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition x:Name="EditColumn"/>
                    <ColumnDefinition x:Name="MapColumn"/>
                </Grid.ColumnDefinitions>
                <Border Name="EditBorder" Grid.Column="0" >
                    <toolkit:Accordion >
                        <toolkit:AccordionItem Header="General Tour Information">
                            <toolkit:DataForm Name="editDataForm"
                                              AutoEdit="True"
                                              AutoCommit="True"
                                              CommandButtonsVisibility="None"
                                              EditTemplate="{StaticResource tourDataFormEditTemplate}"/>
                        </toolkit:AccordionItem>
                        <toolkit:AccordionItem Header="Points of Interest on the Route">
                            <StackPanel>
                                <StackPanel Orientation="Horizontal" >
                                
                                </StackPanel>

                                <toolkit:DataForm x:Name="poiDataForm" 
									        DataContext="{StaticResource poiCollectionViewSource}"
									        ItemsSource="{Binding}"
									        AddingNewItem="poiDataForm_AddingNewItem"
									        ContentLoaded="poiDataForm_ContentLoaded"
									        EditEnded="poiDataForm_EditEnded"
									        CommandButtonsVisibility="All"
									        AutoCommit="True" AutoEdit="True"
									        EditTemplate="{StaticResource poiDataFormEditTemplate}" />
                            </StackPanel>
                        </toolkit:AccordionItem>
                    
                    </toolkit:Accordion>
                
                </Border>
                <Border Name="MapBorder" Grid.Column="1" >
                    <map_namespace:Map Name="mapControl" CredentialsProvider="{Binding MapInfo.CP}"
                                       MouseDoubleClick="mapControl_MouseDoubleClick"
                                       ToolTipService.ToolTip="Double click to create a new interest point">
                        <map_namespace:MapLayer Name="routeLayer"/>
                        <map_namespace:MapLayer Name="pushpinLayer" >
                            <map_namespace:MapItemsControl
						        ItemTemplate="{StaticResource pushPinTemplate}"
						        DataContext="{StaticResource poiCollectionViewSource}"
						        ItemsSource="{Binding}"/>
                        </map_namespace:MapLayer>
                    </map_namespace:Map>
                </Border>
            </Grid>
            <Border Name="WindowControlsBorder" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="2">
                    <Button Name="closeButton" Content="Close"
                            Click="closeButton_Click" Style="{StaticResource RegisterLoginButtonStyle}" />
            </Border>
		</Grid>
	</toolkit:BusyIndicator>
	
</controls:ChildWindow>